package 算法练习;/**
 * @author： li
 * @date： 2022-01-09 18:40
 * @version 1.0
 */

import java.util.Scanner;
public class 礼物01 {
    public static void main(String[] args) {
        int n;
        long s;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        s = sc.nextLong();
        int k;
        if(n%2==0){
             k= n / 2;
        }else {
            k=(n/2)+1;
        }
        long[] sum = new long[2];
        String[] strings = new String[n];
        for (int i = 0; i < n; i++) {
            strings[i] =sc.next();
        }
        int[] max = new int[n];
        for (int t = 1; t <=n-k; t++) {
            for (int i = k-t; i <=k-1; i++) {
                sum[0] = Long.parseLong(strings[i]) + sum[0];
            }

            for (int i =k+t-1;i>=k;i--) {
                sum[1] = Long.parseLong(strings[i]) + sum[1];
            }
            if (sum[0] <= s && sum[1] <= s) {
                max[t]=t;
                sum[0]=sum[1]=0;
            }
        }
        for(int i= n-1;i >= 0;i--){
            if(max[i] != 0){
                System.out.println(max[i]*2);
                break;
            }
        }
    }
}
